﻿using System;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Text;

using ECCIT;
using OgilvyOne.UKNow.IDAL;
using OgilvyOne.UKNow.DALFactory;
using OgilvyOne.UKNow.Model;
using OgilvyOne.UKNow.DAL;
using OgilvyOne.UKNow.Utility;

namespace OgilvyOne.UKNow.BLL
{
    public class EventsPhoneImageBLL
    {
       public int LanguageID { get; set; }
        public EventsPhoneImageBLL(int langID)
        {
            this.LanguageID = langID;
        }

        public ResultInfo Save(EventsImageModel info)
        {
            IDALEventsPhoneImage use = EventsPhoneImageDALFactory.Create(LanguageID);
            info.LanguageID = LanguageID;
            return use.Save(info);
        }
        //删除单个图片的数据
        public ResultInfo delImage(int eid)
        {
            IList<int?> list = new List<int?>();
            list.Add(eid);
            IDALEventsPhoneImage use = EventsPhoneImageDALFactory.Create(LanguageID);
            return use.Delete(list);
        }
        //根据图片id 获取该图片信息
        public EventsImageModel selImage(int id)
        {
            IDALEventsPhoneImage use = EventsPhoneImageDALFactory.Create(LanguageID);
            return use.GetEventsPhoneImageModelByID(id);
        }

        //public ResultInfo DeletePhoneImagesByEventsID(int eventsID)
        //{
        //    return EventsPhoneImageDALFactory.Create(LanguageID).DeleteByEventsID(null, eventsID);
        //}

     
        //修个单个手机图片的发布状态
        public void modPubOne(int eid)
        {
            List<int?> list = new List<int?>();
            list.Add(eid);

            IDALEventsPhoneImage use = EventsPhoneImageDALFactory.Create(LanguageID);

            EventsImageModel model = use.GetEventsPhoneImageModelByID(eid); //查看该图片的当前发布状态
            if (model.State > 0) //该图片的当前为发布状态
            {
                use.UnPublish(list);
                //设置为该图片的state为0 不发布 (传递参数 eid 和 int=0)
            }
            else
            {
                use.Publish(list);
                //设置该图片的state为1 发布     (传递参数 eid 和 int=1)
            }
        }


        //public PagingList GetEventsImageModelsByKeywords(string keyword, int pageSize, int currentPageIndex)
        //{
        //    PagingParameter pagingParams = PagingParameterFactory.CreateInstance(true, currentPageIndex, pageSize, null);
        //    IDALEventsImage use = EventsImageDALFactory.Create(LanguageID);
        //    return use.GetEventsImageModelsByKeywords(keyword, pagingParams);
        //}

        public IList<EventsImageModel> GetAllEventsPhoneImageModels(int? eventsID)
        {
            IDALEventsPhoneImage use = EventsPhoneImageDALFactory.Create(LanguageID);
            return use.GetAllEventsPhoneImageModels(eventsID);
        }

        //public EventsImageModel GetAllEventsImageModelsByIds(int? eventsID)
        //{
        //    IDALEventsImage use = EventsImageDALFactory.Create(LanguageID);
        //    return use.GetEventsImageModelByID(eventsID);
        //}

        //public IList<EventsImageModel> GetPublishedEventsImageModels(int? eventsID)
        //{
        //    return EventsImageDALFactory.Create(this.LanguageID).GetPublishedEventsImageModels(eventsID);
        //}

        //public IList<EventsImageModel> GetPublishedGalleryImageModelsByEventsID(int? eventsID)
        //{
        //    return EventsImageDALFactory.Create(this.LanguageID).GetPublishedGalleryImageModelsByEventsID(eventsID);
        //}

        //public IList<EventsImageModel> GetPublishedGalleryImageModels()
        //{
        //    return EventsImageDALFactory.Create(this.LanguageID).GetPublishedGalleryImageModels();
        //}
        
        private  EventsModel GetMod(int id,int langID)
        {

            return EventsDALFactory.Create(langID).GetEventsModelByID(id);
        }
    }
}
